//
//  WeChatViewController.m
//  Article
//
//  Created by Haricot_cpc17 on 16/4/21.
//  Copyright © 2016年 mac. All rights reserved.
//
//微信
#import "WeChatViewController.h"

@interface WeChatViewController (){
    UITextField *_oldTextfiled;
    UITextField *_newTextfiled;
    UITextField *_ReTextfiled;
}
@property (nonatomic,strong)UITextField *textField;

@end

@implementation WeChatViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
    self.tabBarController.tabBar.translucent = YES;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"arrow"] style:UIBarButtonItemStylePlain target:self action:@selector(back)];
    
    self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    
    self.view.backgroundColor = UIColorFromRGB(0xefeff1);
    
    self.navigationItem.title = @"绑定微信";
    
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate =(id)self;
    
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont fontWithName:@"Heiti SC" size:18],
       NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    [self createUI];
    // Do any additional setup after loading the view.
}
-(void)back{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)createUI{
    _oldTextfiled = [[UITextField alloc]initWithFrame:CGRectMake(WIDTH *20/375, HEIGHT *36/667 + HEIGHT *0/667, WIDTH - WIDTH *40/375, HEIGHT *40/667)];
    _oldTextfiled.secureTextEntry = YES;
    _oldTextfiled.placeholder = @"请输入微信号";
    [_oldTextfiled setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
    [_oldTextfiled setValue:[UIFont fontWithName:@"Heiti SC" size:14 *MYWIDTH] forKeyPath:@"_placeholderLabel.font"];
    [_oldTextfiled setBorderStyle:UITextBorderStyleNone];
    [self.view addSubview:_oldTextfiled];
    _oldTextfiled.borderStyle = UITextBorderStyleRoundedRect;
    _oldTextfiled.secureTextEntry = YES;
    _oldTextfiled.tag = 100;
    
    _newTextfiled = [[UITextField alloc]initWithFrame:CGRectMake(WIDTH *20/375, HEIGHT *36/667 + HEIGHT *60/667, WIDTH - WIDTH *40/375, HEIGHT *40/667)];
    _newTextfiled.secureTextEntry = YES;
    _newTextfiled.placeholder = @"请输入微信昵称";
    [_newTextfiled setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
    [_newTextfiled setValue:[UIFont fontWithName:@"Heiti SC" size:14 *MYWIDTH] forKeyPath:@"_placeholderLabel.font"];
    [_newTextfiled setBorderStyle:UITextBorderStyleNone];
    [self.view addSubview:_newTextfiled];
    _newTextfiled.borderStyle = UITextBorderStyleRoundedRect;
    _newTextfiled.secureTextEntry = YES;
    _newTextfiled.tag = 101;
    
    
    UILabel *phoneNumLabel = [[UILabel alloc]initWithFrame:CGRectMake(WIDTH *30/375, HEIGHT *36/667 + HEIGHT *120/667, WIDTH - WIDTH *260/375, HEIGHT *40/667)];
    NSUserDefaults *user = [[NSUserDefaults alloc]init];
    phoneNumLabel.text = [user objectForKey:@"mobile"];
    phoneNumLabel.font = [UIFont fontWithName:@"Heiti SC" size:15 *MYWIDTH];
    phoneNumLabel.textColor = UIColorFromRGB(0x333333);
    [self.view addSubview:phoneNumLabel];
    
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(WIDTH * 160/375, HEIGHT *36/667 + HEIGHT *120/667, WIDTH - WIDTH *180/375, HEIGHT *35/667)];
    button.backgroundColor = UIColorFromRGB(0xff6a6a);
    button.layer.cornerRadius = 5;
    button.titleLabel.font = [UIFont fontWithName:@"Heiti SC" size:14 *MYWIDTH];
    [button setTitle:@"发送验证码" forState:UIControlStateNormal];
    [self.view addSubview:button];
    
    _ReTextfiled = [[UITextField alloc]initWithFrame:CGRectMake(WIDTH *20/375, HEIGHT *86/667 + HEIGHT *120/667, WIDTH - WIDTH *40/375, HEIGHT *40/667)];
    _ReTextfiled.secureTextEntry = YES;
    _ReTextfiled.placeholder = @"请输入手机验证码";
    [_ReTextfiled setValue:[UIColor lightGrayColor] forKeyPath:@"_placeholderLabel.textColor"];
    [_ReTextfiled setValue:[UIFont fontWithName:@"Heiti SC" size:14 *MYWIDTH] forKeyPath:@"_placeholderLabel.font"];
    [_ReTextfiled setBorderStyle:UITextBorderStyleNone];
    [self.view addSubview:_ReTextfiled];
    _ReTextfiled.borderStyle = UITextBorderStyleRoundedRect;
    _ReTextfiled.secureTextEntry = YES;
    _ReTextfiled.tag = 102;
    
    
    [self.view addSubview:_textField];
    
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(textFieldClick)];
    [self.view addGestureRecognizer:tap];
    
    
    //提交按钮
    UIButton *submitBtn = [[UIButton alloc]initWithFrame:CGRectMake(WIDTH *40/375, HEIGHT *272/667, WIDTH - WIDTH *80/375, HEIGHT *40/667)];
    submitBtn.backgroundColor = UIColorFromRGB(0xff6a6a);
    [submitBtn setTitle:@"确认修改" forState:UIControlStateNormal];
    submitBtn.titleLabel.font = [UIFont fontWithName:@"Heiti SC" size:14 *MYWIDTH];
    [self.view addSubview:submitBtn];
    submitBtn.layer.cornerRadius = 5;
    [submitBtn addTarget:self action:@selector(submitClick:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)submitClick:(UIButton *)button{

    [self.view makeToast:@"该功能暂未开放，敬请期待！" duration:0.5 position:CSToastPositionCenter];
}
-(void)textFieldClick{
    UITextField *textField = [(UITextField *)self.view viewWithTag:100];
    [textField resignFirstResponder];
    
    UITextField *textField1 = [(UITextField *)self.view viewWithTag:101];
    [textField1 resignFirstResponder];
    
    UITextField *textField2 = [(UITextField *)self.view viewWithTag:102];
    [textField2 resignFirstResponder];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
